<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.16"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Livox SDK API: sdk_core/include/comm/comm_port.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="1.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Livox SDK API
   &#160;<span id="projectnumber">V2.0.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.16 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('comm__port_8h_source.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">comm_port.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="comm__port_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment">// The MIT License (MIT)</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment">// Copyright (c) 2019 Livox. All rights reserved.</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment">// Permission is hereby granted, free of charge, to any person obtaining a copy</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment">// of this software and associated documentation files (the &quot;Software&quot;), to deal</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment">// in the Software without restriction, including without limitation the rights</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment">// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment">// copies of the Software, and to permit persons to whom the Software is</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment">// furnished to do so, subject to the following conditions:</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment">// The above copyright notice and this permission notice shall be included in</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment">// all copies or substantial portions of the Software.</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment">// THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment">// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment">// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span></div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="comment">// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span></div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="comment">// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span></div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="comment">// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="comment">// SOFTWARE.</span></div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160; </div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="preprocessor">#ifndef COMM_COMM_PORT_H_</span></div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="preprocessor">#define COMM_COMM_PORT_H_</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160; </div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="preprocessor">#include &lt;stdint.h&gt;</span></div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="protocol_8h.html">protocol.h</a>&quot;</span></div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160; </div>
<div class="line"><a name="l00031"></a><span class="lineno"><a class="line" href="namespacelivox.html">   31</a></span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacelivox.html">livox</a> {</div>
<div class="line"><a name="l00032"></a><span class="lineno"><a class="line" href="namespacelivox.html#aa902d8a50576dcdede27023c03f65747">   32</a></span>&#160;<span class="keyword">const</span> uint32_t <a class="code" href="namespacelivox.html#aa902d8a50576dcdede27023c03f65747">kCacheSize</a> = 8192;</div>
<div class="line"><a name="l00033"></a><span class="lineno"><a class="line" href="namespacelivox.html#a4db2ee1c995aba81900420b7e4312bc1">   33</a></span>&#160;<span class="keyword">const</span> uint32_t <a class="code" href="namespacelivox.html#a4db2ee1c995aba81900420b7e4312bc1">kMoveCacheLimit</a> = 1536;</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160; </div>
<div class="line"><a name="l00035"></a><span class="lineno"><a class="line" href="structlivox_1_1_port_cache.html">   35</a></span>&#160;<span class="keyword">typedef</span> <span class="keyword">struct </span>{</div>
<div class="line"><a name="l00036"></a><span class="lineno"><a class="line" href="structlivox_1_1_port_cache.html#a0162595514fe1687637993072bfad504">   36</a></span>&#160;  uint8_t buf[<a class="code" href="namespacelivox.html#aa902d8a50576dcdede27023c03f65747">kCacheSize</a>];</div>
<div class="line"><a name="l00037"></a><span class="lineno"><a class="line" href="structlivox_1_1_port_cache.html#a307ffa61497df31d0d8b50eb3294ce28">   37</a></span>&#160;  uint32_t <a class="code" href="structlivox_1_1_port_cache.html#a307ffa61497df31d0d8b50eb3294ce28">rd_idx</a>;</div>
<div class="line"><a name="l00038"></a><span class="lineno"><a class="line" href="structlivox_1_1_port_cache.html#a7d3d6b10a8a6bb8ed81c8a67add26b1f">   38</a></span>&#160;  uint32_t <a class="code" href="structlivox_1_1_port_cache.html#a7d3d6b10a8a6bb8ed81c8a67add26b1f">wr_idx</a>;</div>
<div class="line"><a name="l00039"></a><span class="lineno"><a class="line" href="structlivox_1_1_port_cache.html#a2c92155bd2db69e7368a1be11c384cb8">   39</a></span>&#160;  uint32_t <a class="code" href="structlivox_1_1_port_cache.html#a2c92155bd2db69e7368a1be11c384cb8">size</a>;</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;} <a class="code" href="structlivox_1_1_port_cache.html">PortCache</a>;</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160; </div>
<div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="classlivox_1_1_comm_port.html">   42</a></span>&#160;<span class="keyword">class </span><a class="code" href="classlivox_1_1_comm_port.html">CommPort</a> {</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160; <span class="keyword">public</span>:</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;  <a class="code" href="classlivox_1_1_comm_port.html#a5a159a37a2b90e3e99a8a2258494c374">CommPort</a>();</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160; </div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;  <a class="code" href="classlivox_1_1_comm_port.html#a12578479c9799e0e1019e5698841072b">~CommPort</a>();</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160; </div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;  int32_t <a class="code" href="classlivox_1_1_comm_port.html#aa06a75c5c7801967271b8925bd734fd1">Pack</a>(uint8_t *o_buf, uint32_t o_buf_size, uint32_t *o_len, <span class="keyword">const</span> <a class="code" href="structlivox_1_1_comm_packet.html">CommPacket</a> &amp;i_packet);</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160; </div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;  int32_t <a class="code" href="classlivox_1_1_comm_port.html#a0747279cfee5e49d6abe399adbe81e2a">ParseCommStream</a>(<a class="code" href="structlivox_1_1_comm_packet.html">CommPacket</a> *o_pack);</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160; </div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;  uint8_t *<a class="code" href="classlivox_1_1_comm_port.html#abb44afd20231d53d38f477e4b5861711">FetchCacheFreeSpace</a>(uint32_t *o_len);</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160; </div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;  int32_t <a class="code" href="classlivox_1_1_comm_port.html#ab520a4434c8e19868cf3bab6c229ab7d">UpdateCacheWrIdx</a>(uint32_t used_size);</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160; </div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;  uint16_t <a class="code" href="classlivox_1_1_comm_port.html#a921c62e412bfa973effc62d2592eb2ac">GetAndUpdateSeqNum</a>();</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160; </div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160; <span class="keyword">private</span>:</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;  uint32_t GetCacheTailSize();</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160; </div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;  uint32_t GetValidDataSize();</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160; </div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;  <span class="keywordtype">void</span> UpdateCache(<span class="keywordtype">void</span>);</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160; </div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;  <a class="code" href="structlivox_1_1_port_cache.html">PortCache</a> cache_;</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;  <a class="code" href="classlivox_1_1_protocol.html">Protocol</a> *protocol_;</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;  uint32_t parse_step_;</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;  uint16_t seq_num_;</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;};</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160; </div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;}  <span class="comment">// namespace livox</span></div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;<span class="preprocessor">#endif  // COMM_COMM_PORT_H_</span></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<div class="ttc" id="aclasslivox_1_1_comm_port_html_ab520a4434c8e19868cf3bab6c229ab7d"><div class="ttname"><a href="classlivox_1_1_comm_port.html#ab520a4434c8e19868cf3bab6c229ab7d">livox::CommPort::UpdateCacheWrIdx</a></div><div class="ttdeci">int32_t UpdateCacheWrIdx(uint32_t used_size)</div></div>
<div class="ttc" id="aclasslivox_1_1_protocol_html"><div class="ttname"><a href="classlivox_1_1_protocol.html">livox::Protocol</a></div><div class="ttdef"><b>Definition:</b> <a href="protocol_8h_source.html#l00062">protocol.h:62</a></div></div>
<div class="ttc" id="aclasslivox_1_1_comm_port_html_abb44afd20231d53d38f477e4b5861711"><div class="ttname"><a href="classlivox_1_1_comm_port.html#abb44afd20231d53d38f477e4b5861711">livox::CommPort::FetchCacheFreeSpace</a></div><div class="ttdeci">uint8_t * FetchCacheFreeSpace(uint32_t *o_len)</div></div>
<div class="ttc" id="aclasslivox_1_1_comm_port_html_a12578479c9799e0e1019e5698841072b"><div class="ttname"><a href="classlivox_1_1_comm_port.html#a12578479c9799e0e1019e5698841072b">livox::CommPort::~CommPort</a></div><div class="ttdeci">~CommPort()</div></div>
<div class="ttc" id="aclasslivox_1_1_comm_port_html"><div class="ttname"><a href="classlivox_1_1_comm_port.html">livox::CommPort</a></div><div class="ttdef"><b>Definition:</b> <a href="comm__port_8h_source.html#l00042">comm_port.h:42</a></div></div>
<div class="ttc" id="aclasslivox_1_1_comm_port_html_a0747279cfee5e49d6abe399adbe81e2a"><div class="ttname"><a href="classlivox_1_1_comm_port.html#a0747279cfee5e49d6abe399adbe81e2a">livox::CommPort::ParseCommStream</a></div><div class="ttdeci">int32_t ParseCommStream(CommPacket *o_pack)</div></div>
<div class="ttc" id="astructlivox_1_1_port_cache_html_a7d3d6b10a8a6bb8ed81c8a67add26b1f"><div class="ttname"><a href="structlivox_1_1_port_cache.html#a7d3d6b10a8a6bb8ed81c8a67add26b1f">livox::PortCache::wr_idx</a></div><div class="ttdeci">uint32_t wr_idx</div><div class="ttdef"><b>Definition:</b> <a href="comm__port_8h_source.html#l00038">comm_port.h:38</a></div></div>
<div class="ttc" id="aclasslivox_1_1_comm_port_html_aa06a75c5c7801967271b8925bd734fd1"><div class="ttname"><a href="classlivox_1_1_comm_port.html#aa06a75c5c7801967271b8925bd734fd1">livox::CommPort::Pack</a></div><div class="ttdeci">int32_t Pack(uint8_t *o_buf, uint32_t o_buf_size, uint32_t *o_len, const CommPacket &amp;i_packet)</div></div>
<div class="ttc" id="astructlivox_1_1_port_cache_html"><div class="ttname"><a href="structlivox_1_1_port_cache.html">livox::PortCache</a></div><div class="ttdef"><b>Definition:</b> <a href="comm__port_8h_source.html#l00035">comm_port.h:35</a></div></div>
<div class="ttc" id="aprotocol_8h_html"><div class="ttname"><a href="protocol_8h.html">protocol.h</a></div></div>
<div class="ttc" id="aclasslivox_1_1_comm_port_html_a921c62e412bfa973effc62d2592eb2ac"><div class="ttname"><a href="classlivox_1_1_comm_port.html#a921c62e412bfa973effc62d2592eb2ac">livox::CommPort::GetAndUpdateSeqNum</a></div><div class="ttdeci">uint16_t GetAndUpdateSeqNum()</div></div>
<div class="ttc" id="astructlivox_1_1_port_cache_html_a307ffa61497df31d0d8b50eb3294ce28"><div class="ttname"><a href="structlivox_1_1_port_cache.html#a307ffa61497df31d0d8b50eb3294ce28">livox::PortCache::rd_idx</a></div><div class="ttdeci">uint32_t rd_idx</div><div class="ttdef"><b>Definition:</b> <a href="comm__port_8h_source.html#l00037">comm_port.h:37</a></div></div>
<div class="ttc" id="astructlivox_1_1_comm_packet_html"><div class="ttname"><a href="structlivox_1_1_comm_packet.html">livox::CommPacket</a></div><div class="ttdef"><b>Definition:</b> <a href="protocol_8h_source.html#l00043">protocol.h:43</a></div></div>
<div class="ttc" id="anamespacelivox_html"><div class="ttname"><a href="namespacelivox.html">livox</a></div><div class="ttdef"><b>Definition:</b> <a href="comm__port_8h_source.html#l00031">comm_port.h:31</a></div></div>
<div class="ttc" id="anamespacelivox_html_a4db2ee1c995aba81900420b7e4312bc1"><div class="ttname"><a href="namespacelivox.html#a4db2ee1c995aba81900420b7e4312bc1">livox::kMoveCacheLimit</a></div><div class="ttdeci">const uint32_t kMoveCacheLimit</div><div class="ttdef"><b>Definition:</b> <a href="comm__port_8h_source.html#l00033">comm_port.h:33</a></div></div>
<div class="ttc" id="aclasslivox_1_1_comm_port_html_a5a159a37a2b90e3e99a8a2258494c374"><div class="ttname"><a href="classlivox_1_1_comm_port.html#a5a159a37a2b90e3e99a8a2258494c374">livox::CommPort::CommPort</a></div><div class="ttdeci">CommPort()</div></div>
<div class="ttc" id="astructlivox_1_1_port_cache_html_a2c92155bd2db69e7368a1be11c384cb8"><div class="ttname"><a href="structlivox_1_1_port_cache.html#a2c92155bd2db69e7368a1be11c384cb8">livox::PortCache::size</a></div><div class="ttdeci">uint32_t size</div><div class="ttdef"><b>Definition:</b> <a href="comm__port_8h_source.html#l00039">comm_port.h:39</a></div></div>
<div class="ttc" id="anamespacelivox_html_aa902d8a50576dcdede27023c03f65747"><div class="ttname"><a href="namespacelivox.html#aa902d8a50576dcdede27023c03f65747">livox::kCacheSize</a></div><div class="ttdeci">const uint32_t kCacheSize</div><div class="ttdef"><b>Definition:</b> <a href="comm__port_8h_source.html#l00032">comm_port.h:32</a></div></div>
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_5f1136fe404e0a548faf586fae339a6a.html">sdk_core</a></li><li class="navelem"><a class="el" href="dir_fef6b6f1028f30fedf17225feaaa02fe.html">include</a></li><li class="navelem"><a class="el" href="dir_239a77e39c0fcb2f1e08881bb007ba07.html">comm</a></li><li class="navelem"><a class="el" href="comm__port_8h.html">comm_port.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.16 </li>
  </ul>
</div>
</body>
</html>
